package net.sf.midollo.net.httptunnel.client;

import java.io.IOException;
import java.io.OutputStream;

public class HttpTunnelClientOutputStream extends OutputStream {

	protected final HttpTunnelClient client;
	protected final byte[] singleByteBuffer;

	public HttpTunnelClientOutputStream(HttpTunnelClient client) throws IOException {
		this.client = client;
		this.singleByteBuffer = new byte[1];
	}

	public void write(int b) throws IOException {
		this.singleByteBuffer[0] = (byte)b;
		write(this.singleByteBuffer, 0, 1);
	}

	public void write(byte b[]) throws IOException {
		write(b, 0, b.length);
	}

	public void write(byte b[], int off, int len) throws IOException {
		this.client.requestWrite(b, off, len);
	}

	public void flush() throws IOException {
	}

	public void close() throws IOException {
		this.client.close();
	}
}
